﻿using Microsoft.Extensions.Configuration;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Polaris.Common
{
    /// <summary>
    /// 获取.NetCore配置文件信息
    /// </summary>
    public class AppConfig
    {
        /// <summary>
        /// 获取配置文件
        /// </summary>
        /// <param name="Key"></param>
        /// <returns></returns>
        public static string GetConfigInfo(string Key)
        {
            var builder = new ConfigurationBuilder()
                .SetBasePath(Directory.GetCurrentDirectory())
                .AddJsonFile("appsettings.json");

            IConfigurationRoot configuration = builder.Build();
            string configStr = configuration.GetSection($"{Key}").Value;
            if (!string.IsNullOrWhiteSpace(configStr))
            {
                return configStr;
            }
            return null;
        }

    }
}
